<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script src="../../../vue.js"></script>
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <!-- v-for用作将一个数组循环成列表 -->
      <!-- 循环数组 -->
      <ul>
        <li v-for="item,index in users">
          <p>姓名：{{item.name}}</p>
          <p>年龄：{{item.age}}</p></p>
        </li>
      </ul>

      <!-- 循环对象 -->
      <div v-for="value,key in person">
        {{key}}:{{value}}
      </div>

      <!-- 循环字符串 -->
      <div v-for="char,index of str">
        {{index}}---{{char}}
      </div>
      
      <!-- 循环指定次数 -->
      <div v-for="num,index of 10">
        {{index}}--{{num}}

      </div>

    </div>
    <script>
      const vm = new Vue({
        el: '#app',
        data() {
          return {
            users: [
              {
                id: 1,
                name: 'xiaozhang',
                age: 18,
              },
              {
                id: 2,
                name: 'xiaowang',
                age: 28,
              },
              {
                id: 3,
                name: 'xiaoli',
                age: 38,
              },
            ],
            person: {
              id: 3,
              name: 'xiaoli',
              age: 38,
            },
            str:'sdzgvfdbher'
          };
        },
      });
    </script>
  </body>
</html>
